package com.fancy.learncenter.ui.view;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.CardView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.R;
import com.fancy.learncenter.common.MyApplication;
import com.fancy.learncenter.common.Player;
import com.fancy.learncenter.ui.activity.CartoonChildHomeActivity;
import com.fancy.learncenter.utils.ImageUtil;
import com.fancy.learncenter.utils.WXShareUtil;

/**
 * Created by Hyy on 2017/2/14.
 */

public class CartoonCompletePopupWindow extends BasePopupWindow {


    SimpleDraweeView simpleDraweeView;


    public CartoonCompletePopupWindow(Activity mContext) {
        super(mContext);
        this.mContext = mContext;
        initPopup();

    }


    @Override
    public void showPopupWindow() {
        super.showPopupWindow();

        showAtLocation(popopView, Gravity.CENTER, 0, 0);
    }


    View popopView;
    Activity mContext;

    ImageView go_home;

    private void initPopup() {

        popopView = LayoutInflater.from(mContext).inflate(R.layout.popupwindow_everydaywork_complete, null);

        simpleDraweeView = (SimpleDraweeView) popopView.findViewById(R.id.simpleDraweeView);
        go_home = popopView.findViewById(R.id.go_home);


        String urlPath = "res://" + mContext.getPackageName() + "/" + R.mipmap.cartoon_luobo;
        DraweeController draweeController =
                Fresco.newDraweeControllerBuilder()
                        .setUri(urlPath)
                        .setOldController(simpleDraweeView.getController())
                        .setAutoPlayAnimations(true) // 设置加载图片完成后是否直接进行播放
                        .build();
        simpleDraweeView.setController(draweeController);


        popopView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        go_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, CartoonChildHomeActivity.class);
                mContext.startActivity(intent);
            }
        });


        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);

        setOutsideTouchable(false);

        setContentView(popopView);
    }


}
